Skip to main content

Class App<D>

Provides a base implementation for the Meadow App. Use this class for Meadow applications to get strongly-typed access to the current device information.

Assembly: Meadow.dll
View Source
Declaration
public abstract class App<D> : IApp, IAsyncDisposable where D : class, IMeadowDevice

Implements:
Meadow.IApp, System.IAsyncDisposable

Properties

CancellationToken

A cancellation token that is canceled when the application is signaled to shut down

View Source
Declaration
public CancellationToken CancellationToken { get; }

Settings

Settings parsed from the app.config.yaml at startup

View Source
Declaration
public Dictionary<string, string> Settings { get; }

Device

The root Device interface

View Source
Declaration
public static D Device { get; protected set; }

Abort

The app cancellation token

View Source
Declaration
public static CancellationToken Abort { get; protected set; }

Methods

InvokeOnMainThread(Action<object?>, object?)

Invokes an action in the context of the applications main thread

View Source
Declaration
public void InvokeOnMainThread(Action<object?> action, object? state = null)
Parameters
TypeNameDescription
System.Action<System.Object>actionThe action to call
System.ObjectstateAn optional state object to pass to the Action

Run()

Called by MeadowOS when everything is ready for the App to run

View Source
Declaration
public virtual Task Run()
Returns

System.Threading.Tasks.Task

Initialize()

Called by MeadowOS to initialize the App

View Source
Declaration
public virtual Task Initialize()
Returns

System.Threading.Tasks.Task

OnShutdown()

Called when a request to shut down the App occurs

View Source
Declaration
public virtual Task OnShutdown()
Returns

System.Threading.Tasks.Task

OnError(Exception)

Called when the MeadowOS encounters an error

View Source
Declaration
public virtual Task OnError(Exception e)
Returns

System.Threading.Tasks.Task

Parameters
TypeNameDescription
System.ExceptioneThe exception from MeadowOS

OnUpdate(Version, out bool)

Called when the application is about to update itself.

View Source
Declaration
public void OnUpdate(Version newVersion, out bool approveUpdate)
Parameters
TypeName
System.VersionnewVersion
System.BooleanapproveUpdate

OnUpdateComplete(Version, out bool)

Called when the application has updated itself.

View Source
Declaration
public void OnUpdateComplete(Version oldVersion, out bool rollbackUpdate)
Parameters
TypeName
System.VersionoldVersion
System.BooleanrollbackUpdate

DisposeAsync()

Virtual method provided for App implementations to clean up resources on Disposal

View Source
Declaration
public virtual ValueTask DisposeAsync()
Returns

System.Threading.Tasks.ValueTask

Implements